from sqlobject import connectionForURI
from sqlobject.dbconnection import ConnectionHub
import os

hub = ConnectionHub()
__connection__ = hub
connURI = "sqlite://%s" % os.path.realpath("db.sqlite")

def get_conection():
    conn = connectionForURI(connURI)
    conn.makeConnection()
    hub.threadConnection = conn
    return conn

def transaction():
    conn = hub.getConnection()
    conn.autoCommit = 0
    trans = conn.transaction()
    return trans


